package com.example.vue20220402.controller;

import com.alipay.api.AlipayApiException;
import com.example.vue20220402.config.AlipayConfig;
import com.example.vue20220402.pojo.AlipayBean;
import com.example.vue20220402.service.AlipayService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

@RestController
@RequestMapping("/orders")
public class OrderController {

    @Resource
    AlipayService alipayService;

    @RequestMapping("/test")
    public Map<String,String> test(AlipayBean alipayBean) throws AlipayApiException {
        Map<String,String> map = new HashMap<>();
        String facetoface = alipayService.pay(alipayBean);
        map.put("message",facetoface);
        //PrintWriter writer =
        return map;
    }

    @RequestMapping("/notify")
    public Map<String,String> notify(Map<String,String> params ){
        //获取支付宝POST过来反馈信息
        Set<String> strings = params.keySet();
        for(String s : strings)
            System.out.println(s+"--"+params.get(s));
        return params;
    }
}
